﻿@model FineAdmin.Model.MaterialGoodsModel
@{ ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_LayoutForm.cshtml"; }

<form class="layui-form layui-form-pane ok-form" lay-filter="formTest">
    @*一些不需要更新的隐藏字段*@
    @Html.HiddenFor(x => x.Id)
    @Html.HiddenFor(x => x.CreateTime)
    @Html.HiddenFor(x => x.CreateUserId)
   
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" name="Title" placeholder="标题" autocomplete="off" class="layui-input" lay-verify="required">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">推广链接</label>
        <div class="layui-input-block">
            <input type="text" name="ClickUrl" placeholder="推广链接" autocomplete="off" class="layui-input" lay-verify="required">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">二合一链接</label>
        <div class="layui-input-block">
            <input type="text" name="CouponShareUrl" placeholder="二合一链接" autocomplete="off" class="layui-input" lay-verify="required">
        </div>
    </div>
    @*<div class="layui-form-item">
        <label class="layui-form-label">v1</label>
        <div class="layui-input-block">
            <input type="text" name="CategoryV1" placeholder="v1" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">v2</label>
        <div class="layui-input-block">
            <input type="text" name="CategoryV2" placeholder="v2" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">v3</label>
        <div class="layui-input-block">
            <input type="text" name="CategoryV3" placeholder="v3" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">更新间隔-分钟</label>
        <div class="layui-input-block">
            <input type="text" name="UpdateInterval" placeholder="更新间隔" autocomplete="off" class="layui-input" lay-verify="required">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">标定生产数量</label>
        <div class="layui-input-block">
            <input type="text" name="Quantity" placeholder="阿里官方标定的生产数量" autocomplete="off" class="layui-input" lay-verify="required">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">限制生产数量</label>
        <div class="layui-input-block">
            <input type="text" name="LimitQuantity" placeholder="系统限制的生产数量" autocomplete="off" class="layui-input" lay-verify="required">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">排序码</label>
        <div class="layui-input-block">
            <input type="text" name="SortCode" placeholder="排序码" autocomplete="off" class="layui-input" lay-verify="number" maxlength="2">
        </div>
    </div>*@
    @*<div class="layui-form-item">
            <label class="layui-form-label">分类</label>
            <div class="layui-input-block">
                @Html.DropDownList("CategoryId", (IEnumerable<SelectListItem>)ViewBag.CategoryNameList, "请选择分类", new Dictionary<string, object> { { "lay-verify", "required" } })
            </div>
        </div>*@
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="add">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script>
    layui.use(["form", "treeSelect", "okLayer", "okUtils"], function () {
        let treeSelect = layui.treeSelect;
        let form = layui.form;
        let okLayer = layui.okLayer;
        let okUtils = layui.okUtils;
        @*treeSelect.render({
            elem: "#Pid",
            data: "/Shop/AppBarSet/GetAppBarTreeSelect",
            type: "GET"
            @if (Model.Pid!=0)
            {
                <text>,success: function (d) {
                treeSelect.checkNode('tree', "@Model.Pid");
                treeSelect.refresh('tree');
                }</text>
            }
        });*@
        //给表单赋值
        form.val("formTest", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
            "Title": "@Model.Title",
            "ClickUrl": "@Html.Raw(Model.ClickUrl)",
            "CouponShareUrl": "@Html.Raw(Model.CouponShareUrl)",
        });
        form.on("submit(add)", function (data) {
            okUtils.ajax("/Shop/GoodsSet/Edit", "post", data.field, true).done(function (response) {
                okLayer.greenTickMsg(response.message, function () {
                    parent.location.reload(); // 父页面刷新
                    parent.layer.close(parent.layer.getFrameIndex(window.name));//先得到当前iframe层的索引 再执行关闭
                });
            }).fail(function (error) {
                console.log(error)
            });
            return false;
        });
    });
</script>

